package com.cjm.one.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.cjm.one.goods.service.GoodsSpecService;
import com.cjm.one.goods.mapper.GoodsSpecMapper;
import com.cjm.one.model.goods.entity.GoodsSpec;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
* @author 29289
* @description 针对表【goods_spec(商品规格)】的数据库操作Service实现
* @createDate 2024-09-05 16:07:00
*/
@Service
public class GoodsSpecServiceImpl extends ServiceImpl<GoodsSpecMapper, GoodsSpec>
    implements GoodsSpecService{
    @Resource
    private GoodsSpecMapper goodsSpecMapper;

    @Override
    public Page<GoodsSpec> pageList(Long current, Long size, String specName) {
        Page<GoodsSpec> page = new Page<>(current, size);
        LambdaQueryWrapper<GoodsSpec> wrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasText(specName)) {
            wrapper.like(GoodsSpec::getSpecName, specName);
        }
        return goodsSpecMapper.selectPage(page, wrapper);
    }

    @Override
    public List<GoodsSpec> getAll() {
        return goodsSpecMapper.selectList(null);
    }
}




